<?php
namespace App\Api\V1\Models;

use Illuminate\Database\Eloquent\Model;

class Card extends Model
{
    protected $table = 'card';
    public $timestamps = false;
    public function addCardItem($res)
    {
        $data=[
            'name'=>'实体购物卡',
            'description'=>'线下发放',
            'money'=>'500',
            'category'=>'[1,2,3]',
            'exclude_category'=>'[4，5，6]',
            'give_num'=>'100',
            'end_time'=>'0',
            'status'=>'1',

        ];
        $this->name = $data['name'];
        $this->description = $data['description'];
        $this->money = $data['money'];
        $this->category= $data['category'];
        $this->exclude_category = $data['exclude_category'];
        $this->give_num= $data['give_num'];
        $this->end_time= $data['end_time'];
        $this->status = $data['status'];
        if ($this->save()) {
            return $this->toArray();
        }
        return false;
    }
    public function setCardItem($tr)
    {
        $data=[
            'name'=>'线上购物卡',
            'description'=>'线上发放，请通过xxxapp使用',
            'money'=>'500',
            'category'=>'[1,2,3]',
            'exclude_category'=>'[4，5，6]',
            'give_num'=>'100',
            'end_time'=>'0',
            'status'=>'1',

        ];
        $res = card::where('card_id',1)->update($data);
        return false;
    }
    public  function getCardItem()
    {
        $res = card::get()->toarray();

        return json_encode($res);
    }
    public function delCardList()
    {
        $tt=card::where('card_id', 10)->delete();
        if($tt){
            return true;
        }
    }
}
?>
